<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <template v-for="item in hobby">
            <input type="checkbox" v-model ="item.show"><label>{{item.name}}</label>
        </template>
        你喜欢的运动：
        <template v-for =" (item,index) in hobby" v-if="item.show">
            <div @click ="getcheck(index)">
                {{item.name}}
            </div>
        </template>
    </div>
    <script src="../js/vue.js"></script>
    <script>
        const app = new Vue({
            el: "#app",
            data: {
                hobby: [
                    { "name": "游戏", show: false },
                    { "name": "代码", show: true },
                    { "name": "魔域", show: false },
                    { "name": "打牌", show: true },
                    { "name": "游泳", show: false }
                ]
            },
             methods: {
                getcheck(index) {
                    alert(this.hobby[index].name)
                }
            }
        })
    </script>
</body>

</html>